package com.lqk.demo.pessimisticlock.syncmode.sequencecontrol.fixedoperatesequence;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.locks.LockSupport;

/**
 * 固定运行顺序：park & unpark
 * @author lqk
 * @date 2021/12/23 16:26
 */
@Slf4j
public class TestPark {
    public static void main(String[] args) {
        Thread t1 = new Thread(() -> {
            LockSupport.park();
            log.debug("1");
        }, "t1");
        t1.start();

        new Thread(() -> {
            log.debug("2");
            LockSupport.unpark(t1);
        }, "t2").start();
    }
}
